package cn.sciento.farm.devicemanager.gateway.uplink.service.strategy;

import cn.sciento.farm.devicemanager.dao.entity.DevCollection;
import cn.sciento.farm.devicemanager.gateway.model.uplink.CollectionData;
import cn.sciento.farm.devicemanager.gateway.uplink.service.sensor.AbstractMessageDisposeService;
import cn.sciento.farm.devicemanager.service.CollectionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author wumu
 * @version V1.0
 * @date 2/27/18
 * @time 4:25 PM
 */
@Order(2)
@Component(value = "strategyDataDisposeService")
public class DataDisposeService extends AbstractMessageDisposeService {

    Logger logger = LoggerFactory.getLogger(DataDisposeService.class);


    @Autowired
    private CollectionService deviceCollectionService;


    @Autowired
    private StrategyDisposeService strategyService;


    @Override
    public void changeDeviceData(CollectionData collectionData) {
        DevCollection deviceCollection = deviceCollectionService.getByArg(
                collectionData.getEui(),
                collectionData.getNode(),
                collectionData.getCircuit());
        if (deviceCollection == null) {
//            logger.info("没有相关的设备" + collectionData);
            return;
        }
        strategyService.changeDeviceData(deviceCollection, collectionData.getData());
    }





}
